import { Amber } from '../database/database'

export default {
    get : async(id) =>{
        return await Amber.findById(id)
    },
    save : async(amber) => {
        await Amber.upsert(amber);
    },
    del : async (id) =>{
        await Amber.destroy({
            where: { id : id }
        });
    },
    list : async(index = 0, page = 10) =>{
        let count = await Amber.count()
        let data = await Amber.findAll({ offset: index * page, limit: page })
        return {
            count : count,
            data : data,
            index : index,
            page : page
        }
    },
    findStatus : async (status) => {
        return await Amber.findAll({
            where: { status : status }
        });
    }
}